<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>统计出现的字符数量</title>
	</head>
	<body>
		<script>
			var str = 'Apple orange tangerine'
			var count = {} //空对象
			for(var i=0;i<str.length;i++){
				//获取单个字符
				var chars = str.charAt(i);
				if(count[chars]){
					count[chars]++;
				}else{
					count[chars] = 1;
				}
			} 
			console.log(count);
			
			//出现最多次数的字符和其次数
			var max = 0;
			var ch = '';
			for(var k in count){ //k 存储为 属性名
				if(count[k] > max){
					max = count[k];
					ch = k;
				}
			}
			console.log(`最多次字符${ch},出现${max}次`)
		</script>
	</body>
</html>